package com.yanghui.dtracing.core.opentracing.propagation;

import io.opentracing.propagation.Format;

import java.util.HashMap;
import java.util.Map;

public class PropagationRegister {

    private final Map<Format<?>,Injector<?>> injectContainer = new HashMap<>();

    private final Map<Format<?>,Extractor<?>> extractorContainer = new HashMap<>();

    public <C> void registerInjector(Format<C> format,Injector<C> injector){
        injectContainer.put(format,injector);
    }

    public <C> Injector<C> getInjector(Format<C> format){
        return (Injector<C>)injectContainer.get(format);
    }

    public <C> void registerExtractor(Format<C> format,Extractor<C> extractor){
        extractorContainer.put(format,extractor);
    }

    public <C> Extractor<C> getExtractor(Format<C> format){
        return (Extractor<C>)extractorContainer.get(format);
    }
}
